#include "StdAfx.h"
#include "DocumentManager.h"

#include "CodeView.h"


BEGIN_MESSAGE_MAP(CDocumentManager, CCmdTarget)
	ON_COMMAND(ID_VIEW_SCRIPT, OnViewScript)
	ON_UPDATE_COMMAND_UI(ID_VIEW_SCRIPT, OnUpdateViewScript)
	ON_COMMAND(ID_VIEW_HEADER, OnViewHeader)
	ON_UPDATE_COMMAND_UI(ID_VIEW_HEADER, OnUpdateViewHeader)
END_MESSAGE_MAP()


CDocumentManager::CDocumentManager(CResourceDocument &a_rDocument) :
m_rDocument(a_rDocument),
m_ScriptManager(m_rDocument.GetScriptCode()),
m_HeaderManager(m_rDocument.GetHeaderCode())
{
}


VOID CDocumentManager::CloseAllViews()
{
	m_ScriptManager.CloseView();
	m_HeaderManager.CloseView();
}


void CDocumentManager::OnViewScript()
{
	m_ScriptManager.ToggleView();
}

void CDocumentManager::OnUpdateViewScript(CCmdUI *pCmdUI)
{
	pCmdUI->SetCheck(m_ScriptManager.IsViewOpen() ? 1 : 0);
}


void CDocumentManager::OnViewHeader()
{
	m_HeaderManager.ToggleView();
}

void CDocumentManager::OnUpdateViewHeader(CCmdUI *pCmdUI)
{
	pCmdUI->SetCheck(m_HeaderManager.IsViewOpen() ? 1 : 0);
}
